const log4js = require('log4js');
const path = require("path");
const fs = require("fs");
const logs = path.join(__dirname, '../logs');
if (!fs.existsSync(logs)) {//判断文件夹是否存在
    fs.mkdirSync(logs);//新建文件夹
};
//配置信息
log4js.configure({
    appenders: {
        ruleConsole: { type: 'console' },
        ruleFile: {
            type: 'dateFile',
            filename: 'logs/server-',
            pattern: 'yyyy-MM-dd.log',
            maxLogSize: 10 * 1000 * 1000,
            numBackups: 3,
            alwaysIncludePattern: true
        }
    },
    categories: {
        default: { appenders: ['ruleConsole', 'ruleFile'], level: 'info' }
    }
});
const logger = log4js.getLogger('cheese');
logger.level = 'debug';
logger.debug("Some debug messages");
logger.trace('Entering cheese testing');
logger.debug('Got cheese.');
logger.info('Cheese is Gouda.');


module.exports = logger;